<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>i2c: C:/Users/Jon/Downloads/OOP/db-control/dbInternship.php Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">i2c
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">C:/Users/Jon/Downloads/OOP/db-control/dbInternship.php</div>  </div>
</div>
<div class="contents">
<a href="db_internship_8php.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 &lt;?php
<a name="l00002"></a>00002 
<a name="l00026"></a><a class="code" href="classdb_internship.html">00026</a> <span class="keyword">class </span><a class="code" href="classdb_internship.html">dbInternship</a> {
<a name="l00027"></a>00027 
<a name="l00028"></a>00028     <span class="keyword">private</span> $db;
<a name="l00029"></a>00029 
<a name="l00033"></a><a class="code" href="classdb_internship.html#aea6c4d653e217f31256ded5783ed58f4">00033</a>     <span class="keyword">static</span> <span class="keyword">function</span> <a class="code" href="classdb_internship.html#aea6c4d653e217f31256ded5783ed58f4">createTable</a>() {
<a name="l00034"></a>00034         <span class="comment">//Create table internship</span>
<a name="l00035"></a>00035         <a class="code" href="internship__list__dateadded_8php.html#af59a5f7cd609e592c41dc3643efd3c98">$query</a> = <span class="stringliteral">&quot;</span>
<a name="l00036"></a>00036 <span class="stringliteral">            create table internship(</span>
<a name="l00037"></a>00037 <span class="stringliteral">                internshipID            int             NOT NULL AUTO_INCREMENT,</span>
<a name="l00038"></a>00038 <span class="stringliteral">                opportunityID           int             NOT NULL,</span>
<a name="l00039"></a>00039 <span class="stringliteral">                studentID               int             NOT NULL,</span>
<a name="l00040"></a>00040 <span class="stringliteral">                hours                   varchar(25)     NULL,</span>
<a name="l00041"></a>00041 <span class="stringliteral">                special                 varchar(10)     NULL,</span>
<a name="l00042"></a>00042 <span class="stringliteral">                semester                varchar(25)     NULL,</span>
<a name="l00043"></a>00043 <span class="stringliteral">                constraint PK_Contact PRIMARY KEY (internshipID),</span>
<a name="l00044"></a>00044 <span class="stringliteral">                constraint FK_Contact_Opportunity FOREIGN KEY (opportunityID)</span>
<a name="l00045"></a>00045 <span class="stringliteral">                    references opportunity (opportunityID),</span>
<a name="l00046"></a>00046 <span class="stringliteral">                constraint FK_Contact_Student FOREIGN KEY (studentID)</span>
<a name="l00047"></a>00047 <span class="stringliteral">                    references student (studentID)</span>
<a name="l00048"></a>00048 <span class="stringliteral">                );</span>
<a name="l00049"></a>00049 <span class="stringliteral">    &quot;</span>;
<a name="l00050"></a>00050         <a class="code" href="db-control_2inc_2functions_8php.html#aca07cf60afd49a5a5b583459f5423045">connectToDatabase</a>();
<a name="l00051"></a>00051         <a class="code" href="admin_2internship__list_8php.html#a112ef069ddc0454086e3d1e6d8d55d07">$result</a> = mysql_query(<a class="code" href="internship__list__dateadded_8php.html#af59a5f7cd609e592c41dc3643efd3c98">$query</a>);
<a name="l00052"></a>00052         echo mysql_error();
<a name="l00053"></a>00053         mysql_close();
<a name="l00054"></a>00054         <span class="keywordflow">if</span> (<a class="code" href="admin_2internship__list_8php.html#a112ef069ddc0454086e3d1e6d8d55d07">$result</a> == <span class="keyword">false</span>) {
<a name="l00055"></a>00055             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00056"></a>00056         }
<a name="l00057"></a>00057 
<a name="l00058"></a>00058         <span class="comment">//Previous query was successful.</span>
<a name="l00059"></a>00059         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00060"></a>00060     }
<a name="l00061"></a>00061 
<a name="l00066"></a><a class="code" href="classdb_internship.html#a72ba90829ea621f24d39e82f5108e7c7">00066</a>     <span class="keyword">function</span> <a class="code" href="classdb_internship.html#a72ba90829ea621f24d39e82f5108e7c7">getAllInternships</a>() {
<a name="l00067"></a>00067         <a class="code" href="internship__list__dateadded_8php.html#af59a5f7cd609e592c41dc3643efd3c98">$query</a> = <span class="stringliteral">&quot;SELECT * FROM internship&quot;</span>;
<a name="l00068"></a>00068         <a class="code" href="db-control_2inc_2functions_8php.html#aca07cf60afd49a5a5b583459f5423045">connectToDatabase</a>( );
<a name="l00069"></a>00069         <a class="code" href="admin_2internship__list_8php.html#a112ef069ddc0454086e3d1e6d8d55d07">$result</a> = mysql_query(<a class="code" href="internship__list__dateadded_8php.html#af59a5f7cd609e592c41dc3643efd3c98">$query</a>);
<a name="l00070"></a>00070         mysql_close();
<a name="l00071"></a>00071         <span class="keywordflow">if</span> (<a class="code" href="admin_2internship__list_8php.html#a112ef069ddc0454086e3d1e6d8d55d07">$result</a> == <span class="keyword">false</span>) {
<a name="l00072"></a>00072             echo mysql_error( );
<a name="l00073"></a>00073             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00074"></a>00074         }
<a name="l00075"></a>00075 
<a name="l00076"></a>00076         <span class="comment">//Query was successful.</span>
<a name="l00077"></a>00077         <span class="keywordflow">return</span> <a class="code" href="admin_2internship__list_8php.html#a112ef069ddc0454086e3d1e6d8d55d07">$result</a>;
<a name="l00078"></a>00078     }
<a name="l00079"></a>00079 
<a name="l00085"></a><a class="code" href="classdb_internship.html#a156702c426967fbfa4feee8393144711">00085</a>     <span class="keyword">function</span> <a class="code" href="classdb_internship.html#a156702c426967fbfa4feee8393144711">updateInternship</a>($i) {
<a name="l00086"></a>00086         $internshipID = $i-&gt;getInterhshipID();
<a name="l00087"></a>00087         $opportunityID = $i-&gt;getOpportunityID();
<a name="l00088"></a>00088         $studentID = $i-&gt;getStudentID();
<a name="l00089"></a>00089         $hours = $i-&gt;getHours();
<a name="l00090"></a>00090         $special = $i-&gt;getSpecial();
<a name="l00091"></a>00091         $semester = $i-&gt;getSemester();
<a name="l00092"></a>00092 
<a name="l00093"></a>00093         <span class="keywordflow">if</span> ($intershipID == <span class="stringliteral">&#39;&#39;</span>) {
<a name="l00094"></a>00094             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00095"></a>00095         } <span class="keywordflow">else</span> {
<a name="l00096"></a>00096             <span class="keywordflow">if</span> ($opportunityID != <span class="stringliteral">&#39;&#39;</span>) {
<a name="l00097"></a>00097                 <span class="keywordflow">if</span> (!mysql_query(<span class="stringliteral">&quot;UPDATE internship SET opportunityID=</span>
<a name="l00098"></a>00098 <span class="stringliteral">                        &#39;$opportunityID&#39; WHERE internshipID=$internshipID&quot;</span>))
<a name="l00099"></a>00099                     die(<span class="stringliteral">&quot;Could not update internship with ID = $internshipID&quot;</span>);
<a name="l00100"></a>00100             }
<a name="l00101"></a>00101             <span class="keywordflow">if</span> ($studentID != <span class="stringliteral">&#39;&#39;</span>) {
<a name="l00102"></a>00102                 <span class="keywordflow">if</span> (!mysql_query(<span class="stringliteral">&quot;UPDATE internship SET studentID=&#39;$studentID&#39;</span>
<a name="l00103"></a>00103 <span class="stringliteral">                        WHERE internshipID=$internshipID&quot;</span>))
<a name="l00104"></a>00104                     die(<span class="stringliteral">&quot;Could not update internship with ID = $internshipID&quot;</span>);
<a name="l00105"></a>00105             }
<a name="l00106"></a>00106             <span class="keywordflow">if</span> ($hours != <span class="stringliteral">&#39;&#39;</span>) {
<a name="l00107"></a>00107                 <span class="keywordflow">if</span> (!mysql_query(<span class="stringliteral">&quot;UPDATE internship SET hours=&#39;$hours&#39; WHERE</span>
<a name="l00108"></a>00108 <span class="stringliteral">                        internshipID=$internshipID&quot;</span>))
<a name="l00109"></a>00109                     die(<span class="stringliteral">&quot;could not update internship with ID = $internshipID&quot;</span>);
<a name="l00110"></a>00110             }
<a name="l00111"></a>00111             <span class="keywordflow">if</span> ($special != <span class="stringliteral">&#39;&#39;</span>) {
<a name="l00112"></a>00112                 <span class="keywordflow">if</span> (!mysql_query(<span class="stringliteral">&quot;UPDATE internship SET special=&#39;$special&#39; WHERE</span>
<a name="l00113"></a>00113 <span class="stringliteral">                        internshipID=$internshipID&quot;</span>))
<a name="l00114"></a>00114                     die(<span class="stringliteral">&quot;could not update internship with ID = $internshipID&quot;</span>);
<a name="l00115"></a>00115             }
<a name="l00116"></a>00116             <span class="keywordflow">if</span> ($semester != <span class="stringliteral">&#39;&#39;</span>) {
<a name="l00117"></a>00117                 <span class="keywordflow">if</span> (!mysql_query(<span class="stringliteral">&quot;UPDATE internship SET semester=&#39;$semester&#39;</span>
<a name="l00118"></a>00118 <span class="stringliteral">                        WHERE internshipID=$internshipID&quot;</span>))
<a name="l00119"></a>00119                     die(<span class="stringliteral">&quot;could not update internship with ID = $internshipID&quot;</span>);
<a name="l00120"></a>00120             }
<a name="l00121"></a>00121 
<a name="l00122"></a>00122             <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00123"></a>00123         }
<a name="l00124"></a>00124     }
<a name="l00125"></a>00125 
<a name="l00131"></a><a class="code" href="classdb_internship.html#a8afa8ee7d70fe41fcf2ccb3105373964">00131</a>     <span class="keyword">function</span> <a class="code" href="classdb_internship.html#a8afa8ee7d70fe41fcf2ccb3105373964">deleteInternship</a>($i) {
<a name="l00132"></a>00132         <span class="keywordflow">if</span> (!$i instanceof <a class="code" href="class_internship.html">Internship</a>) {
<a name="l00133"></a>00133             echo (<span class="stringliteral">&quot;Invalid argument deleteFrom( ) function&lt;br /&gt;&quot;</span>);
<a name="l00134"></a>00134             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00135"></a>00135         }
<a name="l00136"></a>00136 
<a name="l00137"></a>00137         <span class="comment">//Compose the DELETE FROM query string.</span>
<a name="l00138"></a>00138         <a class="code" href="internship__list__dateadded_8php.html#af59a5f7cd609e592c41dc3643efd3c98">$query</a> = sprintf(<span class="stringliteral">&quot;DELETE FROM internship WHERE internshipID = %d&quot;</span>,
<a name="l00139"></a>00139                         $i-&gt;getInternshipID()
<a name="l00140"></a>00140         );
<a name="l00141"></a>00141         <a class="code" href="db-control_2inc_2functions_8php.html#aca07cf60afd49a5a5b583459f5423045">connectToDatabase</a>( );
<a name="l00142"></a>00142         <a class="code" href="admin_2internship__list_8php.html#a112ef069ddc0454086e3d1e6d8d55d07">$result</a> = mysql_query(<a class="code" href="internship__list__dateadded_8php.html#af59a5f7cd609e592c41dc3643efd3c98">$query</a>);
<a name="l00143"></a>00143         mysql_close( );
<a name="l00144"></a>00144         <span class="keywordflow">if</span> (<a class="code" href="admin_2internship__list_8php.html#a112ef069ddc0454086e3d1e6d8d55d07">$result</a> == <span class="keyword">false</span>) {
<a name="l00145"></a>00145             echo mysql_error( );
<a name="l00146"></a>00146             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00147"></a>00147         }
<a name="l00148"></a>00148 
<a name="l00149"></a>00149         <span class="comment">//Query was successful.</span>
<a name="l00150"></a>00150         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00151"></a>00151     }
<a name="l00152"></a>00152 
<a name="l00158"></a><a class="code" href="classdb_internship.html#aeb180b63f0769532646f2e2ee54418a8">00158</a>     <span class="keyword">static</span> <span class="keyword">function</span> <a class="code" href="classdb_internship.html#aeb180b63f0769532646f2e2ee54418a8">addInternship</a>($i, &amp;$id) {
<a name="l00159"></a>00159         <span class="keywordflow">if</span> (!$i instanceof internship) {
<a name="l00160"></a>00160             echo (<span class="stringliteral">&quot;Invalid arguement insertInto ( ) function&lt;br /&gt;&quot;</span>);
<a name="l00161"></a>00161             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00162"></a>00162         }
<a name="l00163"></a>00163         <span class="comment">//Compose the INSERT INTO query srting. Primary key value is missing.</span>
<a name="l00164"></a>00164         <span class="comment">//Database server automatically generates a unique ID for the primary</span>
<a name="l00165"></a>00165         <span class="comment">//key.</span>
<a name="l00166"></a>00166         <a class="code" href="internship__list__dateadded_8php.html#af59a5f7cd609e592c41dc3643efd3c98">$query</a> = sprintf(<span class="stringliteral">&quot;INSERT INTO internship VALUES (null, %d, %d, &#39;%s&#39;,</span>
<a name="l00167"></a>00167 <span class="stringliteral">            &#39;%s&#39;, &#39;%s&#39;)&quot;</span>,
<a name="l00168"></a>00168                         $i-&gt;getOpportunityID(),
<a name="l00169"></a>00169                         $i-&gt;getStudentID(),
<a name="l00170"></a>00170                         $i-&gt;getHours(),
<a name="l00171"></a>00171                         $i-&gt;getSpecial(),
<a name="l00172"></a>00172                         $i-&gt;getSemester()
<a name="l00173"></a>00173         );
<a name="l00174"></a>00174         <a class="code" href="db-control_2inc_2functions_8php.html#aca07cf60afd49a5a5b583459f5423045">connectToDatabase</a>( );
<a name="l00175"></a>00175         <a class="code" href="admin_2internship__list_8php.html#a112ef069ddc0454086e3d1e6d8d55d07">$result</a> = mysql_query(<a class="code" href="internship__list__dateadded_8php.html#af59a5f7cd609e592c41dc3643efd3c98">$query</a>);
<a name="l00176"></a>00176         $id = mysql_insert_id();
<a name="l00177"></a>00177         mysql_close( );
<a name="l00178"></a>00178         <span class="keywordflow">if</span> (<a class="code" href="admin_2internship__list_8php.html#a112ef069ddc0454086e3d1e6d8d55d07">$result</a> == <span class="keyword">false</span>) {
<a name="l00179"></a>00179             echo mysql_error ( );
<a name="l00180"></a>00180             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00181"></a>00181         }
<a name="l00182"></a>00182         <span class="comment">//query was successful.</span>
<a name="l00183"></a>00183         printf(<span class="stringliteral">&quot;Internship added has id %d\n&lt;br /&gt;&quot;</span>, mysql_insert_id());
<a name="l00184"></a>00184         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00185"></a>00185     }
<a name="l00186"></a>00186 
<a name="l00192"></a><a class="code" href="classdb_internship.html#aa526662116332f93636c017f0653fc52">00192</a>     <span class="keyword">function</span> <a class="code" href="classdb_internship.html#aa526662116332f93636c017f0653fc52">checkID</a>($i) {
<a name="l00193"></a>00193         <span class="keywordflow">if</span> (!($i instanceof <a class="code" href="class_internship.html">Internship</a>)) {
<a name="l00194"></a>00194             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00195"></a>00195         }
<a name="l00196"></a>00196         $internshipID = $i-&gt;getIntnershipID();
<a name="l00197"></a>00197         <a class="code" href="db-control_2inc_2functions_8php.html#aca07cf60afd49a5a5b583459f5423045">connectToDatabase</a>();
<a name="l00198"></a>00198         <span class="keywordflow">if</span> (mysql_num_rows(mysql_query(<span class="stringliteral">&quot;SELECT * FROM internship WHERE</span>
<a name="l00199"></a>00199 <span class="stringliteral">                internshipID=$internshipID&quot;</span>)) == <span class="keyword">false</span>) {
<a name="l00200"></a>00200             mysql_close();
<a name="l00201"></a>00201                         <span class="comment">//nothing exists</span>
<a name="l00202"></a>00202             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00203"></a>00203         } <span class="keywordflow">else</span> {
<a name="l00204"></a>00204             <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00205"></a>00205         }
<a name="l00206"></a>00206     }
<a name="l00207"></a>00207 
<a name="l00214"></a><a class="code" href="classdb_internship.html#ad1c9e03d4ccef5cfe64a55d079626ee3">00214</a>     <span class="keyword">function</span> <a class="code" href="classdb_internship.html#ad1c9e03d4ccef5cfe64a55d079626ee3">getInternship</a>($internshipID) {
<a name="l00215"></a>00215 
<a name="l00216"></a>00216         <a class="code" href="admin_2internship__list_8php.html#a112ef069ddc0454086e3d1e6d8d55d07">$result</a> = mysql_query(<span class="stringliteral">&quot;SELECT * FROM internship WHERE internshipID=</span>
<a name="l00217"></a>00217 <span class="stringliteral">                $internshipID&quot;</span>);
<a name="l00218"></a>00218         <span class="keywordflow">if</span> (!<a class="code" href="admin_2internship__list_8php.html#a112ef069ddc0454086e3d1e6d8d55d07">$result</a>) {
<a name="l00219"></a>00219             <span class="keywordflow">return</span> <span class="keyword">false</span>; <span class="comment">//id does not exist</span>
<a name="l00220"></a>00220         } <span class="keywordflow">else</span> {
<a name="l00221"></a>00221             $row = mysql_fetch_assoc(<a class="code" href="admin_2internship__list_8php.html#a112ef069ddc0454086e3d1e6d8d55d07">$result</a>);
<a name="l00222"></a>00222             $i-&gt;setIntenrshipID($internshipID);
<a name="l00223"></a>00223             $i-&gt;setSemester($row[<span class="stringliteral">&#39;semester&#39;</span>]);
<a name="l00224"></a>00224             <span class="keywordflow">return</span> $i;
<a name="l00225"></a>00225         }
<a name="l00226"></a>00226     }
<a name="l00227"></a>00227 
<a name="l00234"></a><a class="code" href="classdb_internship.html#a5f2f15942d7fed019fe07017d3f12b30">00234</a>     <span class="keyword">function</span> <a class="code" href="classdb_internship.html#a5f2f15942d7fed019fe07017d3f12b30">getStudentID</a>($val) {
<a name="l00235"></a>00235         <a class="code" href="admin_2internship__list_8php.html#a112ef069ddc0454086e3d1e6d8d55d07">$result</a> = mysql_query(<span class="stringliteral">&quot;SELECT studentID FROM internship WHERE</span>
<a name="l00236"></a>00236 <span class="stringliteral">                internshipID=&#39;$val&#39;&quot;</span>);
<a name="l00237"></a>00237         $row = mysql_fetch_row(<a class="code" href="admin_2internship__list_8php.html#a112ef069ddc0454086e3d1e6d8d55d07">$result</a>);
<a name="l00238"></a>00238         <span class="keywordflow">return</span> $row[0];
<a name="l00239"></a>00239     }
<a name="l00240"></a>00240 
<a name="l00246"></a><a class="code" href="classdb_internship.html#a3f100c306bc8417defd1a1ae7ce1ea85">00246</a>     <span class="keyword">function</span> <a class="code" href="classdb_internship.html#a3f100c306bc8417defd1a1ae7ce1ea85">getOpportunityID</a>($val) {
<a name="l00247"></a>00247         <a class="code" href="admin_2internship__list_8php.html#a112ef069ddc0454086e3d1e6d8d55d07">$result</a> = mysql_query(<span class="stringliteral">&quot;SELECT opportunityID FROM internship WHERE</span>
<a name="l00248"></a>00248 <span class="stringliteral">                internshipID=&#39;$val&#39;&quot;</span>);
<a name="l00249"></a>00249         $row = mysql_fetch_row(<a class="code" href="admin_2internship__list_8php.html#a112ef069ddc0454086e3d1e6d8d55d07">$result</a>);
<a name="l00250"></a>00250         <span class="keywordflow">return</span> $row[0];
<a name="l00251"></a>00251     }
<a name="l00252"></a>00252 
<a name="l00258"></a><a class="code" href="classdb_internship.html#a6d5c6a072a550335ffd0fddbc943e13f">00258</a>     <span class="keyword">function</span> <a class="code" href="classdb_internship.html#a6d5c6a072a550335ffd0fddbc943e13f">getHours</a>($internshipID) {
<a name="l00259"></a>00259         <a class="code" href="admin_2internship__list_8php.html#a112ef069ddc0454086e3d1e6d8d55d07">$result</a> = mysql_query(<span class="stringliteral">&quot;SELECT hours FROM internship WHERE</span>
<a name="l00260"></a>00260 <span class="stringliteral">                internshipID=&#39;$val&#39;&quot;</span>);
<a name="l00261"></a>00261         $row = mysql_fetch_row(<a class="code" href="admin_2internship__list_8php.html#a112ef069ddc0454086e3d1e6d8d55d07">$result</a>);
<a name="l00262"></a>00262         <span class="keywordflow">return</span> $row[0];
<a name="l00263"></a>00263     }
<a name="l00264"></a>00264 
<a name="l00270"></a><a class="code" href="classdb_internship.html#a5e7864d0b2187b4c6a8530755d652443">00270</a>     <span class="keyword">function</span> <a class="code" href="classdb_internship.html#a5e7864d0b2187b4c6a8530755d652443">getSemester</a>($val) {
<a name="l00271"></a>00271         <a class="code" href="admin_2internship__list_8php.html#a112ef069ddc0454086e3d1e6d8d55d07">$result</a> = mysql_query(<span class="stringliteral">&quot;SELECT semester FROM internship WHERE</span>
<a name="l00272"></a>00272 <span class="stringliteral">                internshipID=&#39;$val&#39;&quot;</span>);
<a name="l00273"></a>00273         <span class="keywordflow">if</span> (!<a class="code" href="admin_2internship__list_8php.html#a112ef069ddc0454086e3d1e6d8d55d07">$result</a>) {
<a name="l00274"></a>00274             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00275"></a>00275         }
<a name="l00276"></a>00276         $row = mysql_fetch_row(<a class="code" href="admin_2internship__list_8php.html#a112ef069ddc0454086e3d1e6d8d55d07">$result</a>);
<a name="l00277"></a>00277         <span class="keywordflow">return</span> $row[0];
<a name="l00278"></a>00278     }
<a name="l00279"></a>00279 
<a name="l00285"></a><a class="code" href="classdb_internship.html#a72f2b9013e3ea001a8696f570e8cc99b">00285</a>     <span class="keyword">function</span> <a class="code" href="classdb_internship.html#a72f2b9013e3ea001a8696f570e8cc99b">getSpecial</a>($val) {
<a name="l00286"></a>00286         <a class="code" href="admin_2internship__list_8php.html#a112ef069ddc0454086e3d1e6d8d55d07">$result</a> = mysql_query(<span class="stringliteral">&quot;SELECT special FROM internship WHERE</span>
<a name="l00287"></a>00287 <span class="stringliteral">                internshipID=&#39;$val&#39;&quot;</span>);
<a name="l00288"></a>00288         $row = mysql_fetch_row(<a class="code" href="admin_2internship__list_8php.html#a112ef069ddc0454086e3d1e6d8d55d07">$result</a>);
<a name="l00289"></a>00289         <span class="keywordflow">return</span> $row[0];
<a name="l00290"></a>00290     }
<a name="l00291"></a>00291 
<a name="l00296"></a><a class="code" href="classdb_internship.html#aaaca33ac319178544c7cc9df0d9f1578">00296</a>     <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">function</span> <a class="code" href="classdb_internship.html#aaaca33ac319178544c7cc9df0d9f1578">getAllByID</a>($id, &amp;$output) {
<a name="l00297"></a>00297         <a class="code" href="internship__list__dateadded_8php.html#af59a5f7cd609e592c41dc3643efd3c98">$query</a> = sprintf(<span class="stringliteral">&quot;SELECT opportunityID, studentID, hours,</span>
<a name="l00298"></a>00298 <span class="stringliteral">            special, semester FROM internship WHERE</span>
<a name="l00299"></a>00299 <span class="stringliteral">            internshipID=%d&quot;</span>, $id);
<a name="l00300"></a>00300         <span class="comment">//printf(&quot;-&gt;Query: %s&lt;br /&gt;&quot;, $query);</span>
<a name="l00301"></a>00301         <a class="code" href="db-control_2inc_2functions_8php.html#aca07cf60afd49a5a5b583459f5423045">connectToDatabase</a>();
<a name="l00302"></a>00302         <a class="code" href="admin_2internship__list_8php.html#a112ef069ddc0454086e3d1e6d8d55d07">$result</a> = mysql_query(<a class="code" href="internship__list__dateadded_8php.html#af59a5f7cd609e592c41dc3643efd3c98">$query</a>);
<a name="l00303"></a>00303         mysql_close();
<a name="l00304"></a>00304 
<a name="l00305"></a>00305         <span class="keywordflow">if</span> (<a class="code" href="admin_2internship__list_8php.html#a112ef069ddc0454086e3d1e6d8d55d07">$result</a> == <span class="keyword">false</span>) {
<a name="l00306"></a>00306             $output = sprintf(<span class="stringliteral">&quot;%s&quot;</span>, mysql_error());
<a name="l00307"></a>00307             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00308"></a>00308         }
<a name="l00309"></a>00309         <span class="comment">//process result and print out warning or attribute values</span>
<a name="l00310"></a>00310         <span class="keywordflow">return</span> dbInternship::checkForOneInstance(<a class="code" href="admin_2internship__list_8php.html#a112ef069ddc0454086e3d1e6d8d55d07">$result</a>, $id, $output);
<a name="l00311"></a>00311     }
<a name="l00312"></a>00312 
<a name="l00318"></a>00318     <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">function</span> checkForOneInstance(<a class="code" href="admin_2internship__list_8php.html#a112ef069ddc0454086e3d1e6d8d55d07">$result</a>, $id, &amp;$output) {
<a name="l00319"></a>00319         <span class="comment">//Local variables are initialized.</span>
<a name="l00320"></a>00320         $errorStatus = <span class="keyword">false</span>;
<a name="l00321"></a>00321 
<a name="l00322"></a>00322         $howMany = mysql_num_rows(<a class="code" href="admin_2internship__list_8php.html#a112ef069ddc0454086e3d1e6d8d55d07">$result</a>);
<a name="l00323"></a>00323         <span class="keywordflow">switch</span> ($howMany) {
<a name="l00324"></a>00324             <span class="keywordflow">case</span> 0:
<a name="l00325"></a>00325                 $output = sprintf(<span class="stringliteral">&quot;No Interhsnip instance with ID=%d was found.&quot;</span>,
<a name="l00326"></a>00326                                 $id);
<a name="l00327"></a>00327                 $errorStatus = <span class="keyword">true</span>;
<a name="l00328"></a>00328                 <span class="keywordflow">break</span>;
<a name="l00329"></a>00329             <span class="keywordflow">case</span> 1:
<a name="l00330"></a>00330                 <span class="comment">//mysql_fetch() DOES NOT return primary key values</span>
<a name="l00331"></a>00331                 $output = mysql_fetch_assoc(<a class="code" href="admin_2internship__list_8php.html#a112ef069ddc0454086e3d1e6d8d55d07">$result</a>);
<a name="l00332"></a>00332                 $errorStatus = <span class="keyword">false</span>;
<a name="l00333"></a>00333                 <span class="keywordflow">break</span>;
<a name="l00334"></a>00334             <span class="keywordflow">default</span>:
<a name="l00335"></a>00335                 $output = sprintf(<span class="stringliteral">&quot;There are multiple Internship instances with</span>
<a name="l00336"></a>00336 <span class="stringliteral">                                  ID=%d.&quot;</span>, $id);
<a name="l00337"></a>00337                 $errorStatus = <span class="keyword">true</span>;
<a name="l00338"></a>00338                 <span class="keywordflow">break</span>;
<a name="l00339"></a>00339         }
<a name="l00340"></a>00340         <span class="keywordflow">return</span> $errorStatus;
<a name="l00341"></a>00341     }
<a name="l00342"></a>00342 }
<a name="l00343"></a>00343 ?&gt;
<a name="l00344"></a>00344 
</pre></div></div>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>



<hr class="footer"/><address class="footer"><small>
Generated on Tue Nov 29 2011 18:18:54 for i2c by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.5.1
</small></address>

</body>
</html>
